local jiefan = fk.CreateSkill{
  name = "ls__jiefan",
  tags = {"ready_skill"},
}

Fk:loadTranslationTable{
  ["ls__jiefan"] = "解烦",
  [":ls__jiefan"] = "蓄势技，出牌阶段，你可视为使用【援护】并摸一张牌；你使用【杀】后，若此技能已行置，你令重置此技能的弃牌数-1。",
  ["#lvshi__jiefan-invoke"] = "你可视为使用【援护】并摸一张牌",
  ["@ls__jiefan"] = "解烦",

  ["$ls__jiefan1"] = "时局万不至于此，主公无忧！",
  ["$ls__jiefan2"] = "袭敌断锐，遣将增兵。",
}

local DIY = require "packages/diy_utility/diy_utility"

jiefan:addEffect("viewas", {
  prompt = "#lvshi__jiefan-invoke",
  anim_type = "support",
  pattern = "lvshi__support",
  card_filter = Util.FalseFunc,
  view_as = function(self, player, cards)
    if #cards ~= 0 then return end
    local c = Fk:cloneCard("lvshi__support")
    c.skillName = jiefan.name
    return c
  end,
  enabled_at_play = function(self, player)
    return not DIY.isReadying(player, jiefan.name)
  end,
  after_use = function(self, player, use)
    player:drawCards(1, jiefan.name)
  end,
})

jiefan:addEffect(fk.CardUseFinished, {
  can_refresh = function(self, event, target, player, data)
    return player:hasSkill(jiefan.name, true) and target == player and data.card.trueName == "slash" and
    DIY.isReadying(player, jiefan.name)
  end,
  on_refresh = function(self, event, target, player, data)
    DIY.changeReadyProgress(player, jiefan.name, 1, jiefan.name)
  end,
})

return jiefan